class PostsController < ApplicationController

  before_action :contact_me, :set_banner

  before_action :find_post, only: [:show, :previous, :next]

  def index
    @posts = Post.language(current_language).by_created_at_desc.paginate(page: params[:page])
  end

  def show
  end

  def previous
    redirect_to @post.previous(current_language)
  end

  def next
    redirect_to @post.next(current_language)
  end

  private

  def find_post
    @post = Post.find(params[:id])
  end

  def set_banner
    @banner = Banner.post.first
  end
end
